from django.db import models
from utils.base_models import BaseModel
import uuid


class TestsuiteSet(BaseModel):
    name = models.CharField(verbose_name='场景集名称', max_length=200, unique=True, null=False, blank=False)
    level_choice = (
        ('LOW', '低'),
        ('NORMAL', '中'),
        ('HIGH', '高'),
        ('HIGHER', '更高'),
    )
    level = models.CharField(max_length=12, null=False, blank=False, default='NORMAL', choices=level_choice,
                             verbose_name='场景集级别')
    project = models.ForeignKey(to='Projects', on_delete=models.SET_NULL, null=True,
                                blank=True,
                                related_name='testsuite_set', help_text='所属项目 ')
    status_choice = (
        ('INITIAL', '初始状态'),
        ('FAIL', '全部失败'),
        ('PASS', '全部通过'),
        ('PARTIAL_PASS', '部分通过')
    )
    status = models.CharField(max_length=12, null=False, blank=False, default='INITIAL', choices=status_choice,
                              verbose_name='是否测试通过')
    desc = models.CharField(verbose_name='描述信息', max_length=200, null=True, blank=True, default='', help_text='描述信息')
    testsuite = models.ManyToManyField(to='Testsuite', related_name='testsuite_set', through='TestsuiteSet2Testsuite',
                                       through_fields=("testsuite_set", "testsuite"),
                                       verbose_name='测试场景')
    active_choices = (
        (True, '启用'),
        (False, '禁用')
    )
    dingTalk = models.BooleanField(choices=active_choices, default=False, null=False, blank=False, verbose_name='启用/禁用')

    class Meta:
        verbose_name = '场景集组织详情'
        verbose_name_plural = verbose_name
        db_table = 'http_testsuite_set'
        ordering = ('-create_time',)
